<?php
	include "header.php";
	$userid = $_COOKIE['userid'] ? $_COOKIE['userid'] : $_GET['userid'];

	$page = isset($_GET['page']) ? intval($_GET['page']) : 0;					// 开始页
	$pagesize = isset($_GET['pagesize']) ? intval($_GET['pagesize']) : 10;		// 页码


	$redis = connect_redis();
	$mysend_list = $redis->zRevRange("userweibo:list:userid".$userid,0,-1);			// 获取我所有动态

	$weibo_list = array();
	foreach ($mysend_list as $key => $value) {
		$weibo_list[] = [
			"weibo_id" => $value,
			"userid" => $userid,
			"content" => $redis->hget("weibo:data:weiboid".$value,'content'),
			"create_time" => best_time($redis->hget("weibo:data:weiboid".$value,'create_time')),
		];
	}

	// var_dump($weibo_list);
	// die;

?>
<style>
	.mysend_list {
		margin-top:35px;
	}
	.mysend_list ul li {margin-bottom:15px;border-bottom:#ccc 1px dashed;padding:6px 2px;}
	.mysend_list ul li p {font-size:14px;color:#666;margin-top:3px;}
</style>
<div id="content">
	<!-- <h1>我这里是主页</h1> -->
	<div class="publish">
		<form action="action.php?type=sendweibo" method="post">
			<textarea placeholder="哥，大老远来讲点啥吧..." name="content" rows="12" cols="90" style="resize:none;padding:5px 6px" autofocus="true"></textarea>
			<input type="hidden" name="userid" value="<?php echo $userid?>"/>
			<br/><br/>
			<input type="submit" value="发布" style="padding: 9px 15px;background:green;color:white;border:green 1px solid"/>
		</form>
	</div>
	
	<div class="mysend_list">
		<h3 style="margin-bottom:5px;">我的动态</h3>
		<ul>
			<?php
				if(!empty($weibo_list)) {
					foreach ($weibo_list as $k=>$v) {
						echo "<li>".$v['content']."<p>".$v['create_time']."</p>".
							"<p><a href=\"action.php?type=delWeibo&weibo_id=".$v['weibo_id']."\">删除</a>  &nbsp;<a href='#'>上锁</a>"
						."</a></p></li>";
					}
				}else {
					echo "暂无数据，赶快发一条吧…………";
				}
				
			?> 
		<!-- 	<li>
				我今天没做啥啊
				<p>6天前</p>
				<p>
					<a href="action.php?type=delWeibo&weibo_id">删除</a>
					<a href="action.php?type=delWeibo&weibo_id">加锁</a>
				</p>
			</li> -->

			<!-- <li>
				我今天没做啥啊
				<p>6天前</p>
			</li> -->
		</ul>
	</div>
	

</div>

			
<?php
include "footer.php";
?>

